package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.*;

@Getter@Setter@ToString
@JsonIgnoreProperties("handler")
public class FriendshipComment extends BaseDomain {

    public static final Boolean READ_ALREADY=true;//已读
    public static final Boolean READ_UNREAD=false;//未读

    private Friendship friendship;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GTM+8")
    private Date createTime;

    private User user;

    private String content;

    private Boolean read=READ_UNREAD;//默认未读

    //回复集合
    private List<FriendshipReply> friendshipReplies =new ArrayList<>();

    public Object getJson(){
        Map<String,Object> map = new HashMap<>();
        if (user != null) {
            map.put("beReplyUserId",user.getId());
            map.put("beReplyUserName",user.getNickName());
        }
        if (friendship != null) {
            map.put("friendshipId",friendship.getId());
        }
        map.put("userCommentId",id);
        return JSONUtil.toJSONString(map);
    }

}